function eid(id)	{return document.getElementById(id);}
function en(name)	{return document.getElementsByName(name)[0];}
function etag(tag)  {return document.getElementsByTagName(tag)[0];}
function goto(url)      {window.location.href=url;}
function url_ajax(url, callback){
    var ajax_object = false;
    var ajax_callback = callback;
    try{ajax_object = new XMLHttpRequest();}
    catch(try_microsoft){
        try{ajax_object = new ActiveXObject('Msxml2.XMLHTTP');}
        catch(other_microsoft){
            try{ajax_object = new ActiveXObject('Microsoft.XMLHTTP');}
            catch(failed){return false;}
        }
    }
    ajax_object.onreadystatechange = function(){
        if(ajax_object.readyState==4){
            if(ajax_object.status==200){
                ajax_callback(ajax_object.responseText);
                delete ajax_object;
            }
        }
    };
    ajax_object.open('GET', url, true);
    ajax_object.send(null);
    return true;
}

///////////////////////////////////////////////////////////////////////////
function matchChangeProvince(province){
    url_ajax("?_c=match&_f=province&province="+encodeURIComponent(province),function(pc){
        var sel = en("tCity"), ary = pc.split("\n");
        for(var i=sel.options.length-1;i>0;i--){ sel.options.remove(i); }
        for(i=0;i<ary.length;i++){ if(ary[i]!=''){ sel.options.add(new Option(ary[i],ary[i])); } }
        //
        matchCheckField("City");
    });
}
var matchCheckFieldOkCount = 1;//默认性别是 ok 的
var matchCheckFieldState = {"Word":-1,"Name":-1,"Sex":1,"City":-1,"Month":-1,"Job":-1,"Mobile":-1};
function matchCheckField(type){
    var b = 0;
    if(type=="Word"){           b = (en("t"+type).value.length>0)?1:-1;
    }else if(type=="Name"){     b = (en("t"+type).value.length>0)?1:-1;
    }else if(type=="Sex"){
    }else if(type=="City"){     b = (en("tProvince").value!="省份" && en("tCity").value!="城市")?1:-1;
    }else if(type=="Month"){    b = (en("tYear").value!="年" && en("tMonth").value!="月")?1:-1;
    }else if(type=="Job"){      b = (en("t"+type).value.length>0)?1:-1;
    }else if(type=="Mobile"){   b = (parseInt(en("tMobile").value).toString().length==11)?1:-1;
    }
    if(b!=0 && matchCheckFieldState[type]!=b){
        matchCheckFieldOkCount+=b;              //matchCheckFieldOkCount == 7 表示全部都通过
        matchCheckFieldState[type]=b;
        eid("i"+type).src="v/m/images/match_reg_2_"+(b==1?"y":"n")+".png";
    }
}
function matchSubmitFields(){
    if(matchCheckFieldOkCount==7){
        
        return true;
    }else{
        alert("请正确填写资料！");
        return false;
    }
}
///////////////////////////////////////////////////////////////////////
function matchMsgsSend(){
    var e = en("taSendMsg");
    if(e.value!=""){
        url_ajax("?_c=match&_f=msgssend&mid="+en("matchid").value+"&content="+encodeURIComponent(e.value),function(pc){
            alert(pc);
        });
        return true;
    }
    e.value="";
}
function matchMsgSend(){
    var e = en("taSendMsg");
    if(e.value!="" && e.value!=e.title){
        url_ajax("?_c=match&_f=msgsend&pid="+en("playerid").value+"&content="+encodeURIComponent(e.value),function(pc){
            eid("playerMsgCount").innerHTML=(1*eid("playerMsgCount").outerText)+1;
            showRetDialog("msgok");
        });
        return true;
    }
    e.value=e.title;
}
function matchMsgsVote(msgid){
    url_ajax("?_c=match&_f=msgvote&msgid="+msgid,function(pc){
        alert(pc);
    });
}
function matchVote(){
    url_ajax("?_c=match&_f=vote&pid="+en("playerid").value,function(pc){
        if(pc==""){
            showRetDialog("remain");
        }else{
            eid("playerVoteCount").innerHTML=(1*eid("playerVoteCount").outerText)+1;
            eid("yourVoteRemain").innerHTML=(1*eid("yourVoteRemain").outerText)-1;
            eid("yourPoints").innerHTML=(1*eid("yourPoints").outerText)+2;
            alert(pc);
        }
    });
}




//ad用的JS

// 根据省份改变城市的选项
function getcity(){
    var sz=Array();
	sz['省份']=['城市'];
    sz['湖南']=['长沙','郴州','凤凰'];
    sz['湖北']=['武汉','黄石','襄阳'];
    sz['河南']=['郑州','洛阳','南阳'];
    sz['河北']=['石家庄','保定','邯郸'];
    sz['广东']=['广州','深圳'];
    city.length=0;//清除增加的长度    
    var pro=province.value;//获取选中项
    for(var i=0;i<sz[pro].length;i++){
        var op=new Option(sz[pro][i],sz[pro][i]);
        city.add(op);
    }  
}   
// 获取省份选项
function initprovince(var1){
    var pro=Array();
    pro=['省份','湖南','湖北','河南','河北','广东'];
    for(var i=0;i<pro.length;i++){
        var op=new Option(pro[i],pro[i]);
        province.add(op);
        if(var1==pro[i]){
            province.selectedIndex=i;
        }
    }
}
// 获取职业的选项
function initprofession(var1){
    var pro=Array();
    pro=['职业','教师','学生','程序员'];
    for(var i=0;i<pro.length;i++){
        var op=new Option(pro[i],pro[i]);
        profession.add(op);
        if(var1==pro[i]){
            profession.selectedIndex=i;
        }
    }
}
// 检测是否为数字
function isnum(var1){
    if(eid(var1).value!=''){
        var pre=/^\d+$/;
        if(pre.test(eid(var1).value)){
        }else{
        alert("请在"+eid(var1).name+"输入数字");
        }
    }
    else{
        alert("请在"+eid(var1).name+"输入数字");
    }
}

function inputnum(var1){

}